var curData;
var DEFAULT_IMG = '';			//这里设置默认图片
var YOUTUBE_VOD_SEEK="youtube_vod_seek_";			//youtube seek 设置
var seekObj = new Object();
$(function(){
	if(_isAli){
		IMPlayer.CheckConnection ();
		IMPlayer.UpdateStatusSignal.connect(OnStateChanged);
	}
	window.addEventListener("pagehide", pageHide, false);
	
	
	
	curData = {
		id:1,
		title:'Youtube VOd 播放1',	
		img:'',	
		curItemId:2,				//记录正在播放的地址,从1开始
		list:[{
			url:'#',				//记录要播放的页面链接
			name:'1',
		},{
			url:'#',				//记录要播放的页面链接
			name:'2',
		},{
			url:'#',				//记录要播放的页面链接
			name:'3',
		}]		
	}

	//获取该节目的seek时间
	var str = $.getLocal(YOUTUBE_VOD_SEEK+curData.id);
	if(str){ 
		eval("seekObj="+str);
	}
	
	//播放vod
	playVod();
})

function pageHide(){
	if(curPlayData){
		var cur = JP.getCurTime();
		var dur = JP.getDuration();
		if(cur>0 && cur<=(dur - 10)){		//中间换台
			seekObj[curPlayData.curItemId] = cur;
		}
	}
	
	$.setLocal(YOUTUBE_VOD_SEEK+curData.id,$.toJSON(seekObj));
	IMPlayer.Stop();
}


function playVod(){
	var data = curData.list[curData.curItemId - 1];
	if(data.playUrl){
		play(data);
	}else{
		showGPointLoading(550,285);
		KEY.PRESS = false;
		loadPlayURL(data,afterLoadData);
	}
}

function afterLoadData(data,playUrl){ 
	hideGPointLoading();
	KEY.PRESS = true;
	
	data.playUrl = playUrl;
	play(data);
}
